package com.alibaba.algo.components.permission.service.impl;

import com.alibaba.algo.components.permission.domain.SysUserDomain;
import com.alibaba.algo.components.permission.entity.SysUser;
import com.alibaba.algo.components.permission.service.SysUserService;
import com.alibaba.algo.components.permission.dto.SysUserDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 类SysUserServiceImpl.java的实现描述：用户表 serviceimpl
 *
 * @author songwenwei 2020-11-05 16:39:18
 */
@Slf4j
@Service
public class SysUserServiceImpl implements SysUserService {

    @Autowired
    private SysUserDomain sysUserDomain;

    @Override
    public SysUser getById(Long userId) {
        return sysUserDomain.getById(userId);
    }

    @Override
    public List<SysUserDTO> listByPara(SysUserDTO sysUserDTO) {
        SysUser sysUser = new SysUser();
        sysUser.setName(sysUserDTO.getName());
        sysUser.setPasswd(sysUserDTO.getPasswd());
        return sysUserDomain.listByPara(sysUser, null).stream().map(p->new SysUserDTO(p.getId(),p.getName(),p.getPasswd())).collect(Collectors.toList());
    }
}
